<?php

namespace app\api\controller\paotui\poster;

use think\Exception;

/**
 * 通知接口
 */
class Notice extends PosterApi
{

    // 无需登录的接口,*表示全部
    protected $noNeedLogin = [];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = "*";

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 通知列表
     * @throws Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function index(){
        $page = $this->request->post('page',0);
        $limit = $this->request->post('limit',0);

        $postNoticeService = new \addons\paotui\service\PosterNotice();
        $data = $postNoticeService->getNoticeList($page,$limit);

        $this->success('请求成功',$data);
    }

    /**
     * 获取订单详情
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function info(){
        $id = $this->request->post('id',0);
        $postNoticeService = new \addons\paotui\service\PosterNotice();
        $postNoticeInfo = $postNoticeService->getNoticeInfo($id);
        if($postNoticeInfo){
            $this->success("请求成功",$postNoticeInfo);
        }else{
            $this->error("请求失败");
        }
    }
}
